package com.ht.controller;

import com.ht.service.IndexService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/index")
public class IndexController {

    @Resource
    private IndexService indexService;

    @RequestMapping("/countTask")
    public String countTask(HttpSession session, Model model) {
        //请假未审批
        String empId = session.getAttribute("empID").toString();
        int countByTask = indexService.countByTask(empId);
        System.out.println("未审批数量：" + countByTask);
        model.addAttribute("countByTask", countByTask);
        //请假已审批
        String empId1 = session.getAttribute("empID").toString();
        int noByVar = indexService.noByVar(empId1);
        System.out.println("已审批数量：" + noByVar);
        model.addAttribute("noByVar", noByVar);

        //周报已提交
        String empId2 = session.getAttribute("empID").toString();
        int countByWeekly = indexService.countByWeekly(empId2);
        System.out.println("报已提交：" + countByWeekly);
        model.addAttribute("countByWeekly", countByWeekly);
        //周报未提交
        String empId3 = session.getAttribute("empID").toString();
        int noByWeekly = indexService.noByWeekly(empId3);
        System.out.println("周报未提交：" + noByWeekly);
        model.addAttribute("noByWeekly", noByWeekly);

        //谈心记录已提交
        String empId4 = session.getAttribute("empID").toString();
        int countByChc = indexService.countByChc(empId4);
        System.out.println("谈心记录已提交：" + countByChc);
        model.addAttribute("countByChc", countByChc);
        //谈心记录未提交
        String empId5 = session.getAttribute("empID").toString();
        int noByChc = indexService.noByChc(empId5);
        System.out.println("谈心记录未提交：" + noByChc);
        model.addAttribute("noByChc", noByChc);

        //谈心记录已提交
        String empId6 = session.getAttribute("empID").toString();
        int countNoticeRece = indexService.countNoticeRece(empId4);
        System.out.println("公告已读：" + countNoticeRece);
        model.addAttribute("countNoticeRece", countNoticeRece);
        //谈心记录未提交
        String empId7 = session.getAttribute("empID").toString();
        int notNoticeRece = indexService.notNoticeRece(empId7);
        System.out.println("公告未读：" + notNoticeRece);
        model.addAttribute("notNoticeRece", notNoticeRece);

        return "home";
    }

}
